﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.events.*;
    import flash.geom.*;
    import Classes.effects.*;
    import Classes.effects.Particle.*;
    import Display.TrainUI.*;
    import Engine.*;

    public class Train extends Vehicle {

        private const NPCTYPE:String = "train";

        protected var m_pick:TrainSlidePick = null;
        protected var m_trainSmokeEffect:TrainSmokeEffect = null;
        protected var m_smokeEffectOn:Boolean = false;
        protected var m_allowSmoke:Boolean;
        protected var m_friendUID:String = "";

        public function Train(_arg1:String, _arg2:Boolean){
            super(_arg1, _arg2);
            setShowHighlight(false);
            m_typeName = this.NPCTYPE;
            this.m_allowSmoke = (m_item.smokeXml.@show == "true");
        }
        override protected function onItemImageLoaded(_arg1:Event):void{
            super.onItemImageLoaded(_arg1);
            if (this.m_smokeEffectOn){
                this.addSmokeEffect();
            };
        }
        protected function addSmokeEffect():void{
            var _local1:MapResourceEffect;
            if (!this.m_trainSmokeEffect){
                _local1 = addAnimatedEffect(EffectType.TRAIN_SMOKE);
                if (((_local1) && ((_local1 is TrainSmokeEffect)))){
                    this.m_trainSmokeEffect = (_local1 as TrainSmokeEffect);
                };
            };
        }
        override public function get isHighlightable():Boolean{
            return (true);
        }
        override public function get canShowHighlight():Boolean{
            return (false);
        }
        override protected function calculateDepthIndex():void{
            super.calculateDepthIndex();
            if ((((m_direction == Constants.DIRECTION_NE)) || ((m_direction == Constants.DIRECTION_NW)))){
                m_depthIndex = (m_depthIndex - (5 * 1000));
            };
        }
        public function setPick(_arg1:TrainSlidePick):void{
            this.m_pick = _arg1;
        }
        public function setFriend(_arg1:String):void{
            this.m_friendUID = _arg1;
        }
        override public function isPixelInside(_arg1:Point):Boolean{
            var _local2:Rectangle;
            if (((((this.m_pick) && (m_displayObject))) && (m_displayObject.getRect(m_displayObject.parent).containsPoint(_arg1)))){
                _local2 = this.m_pick.getPickSprite().getRect(m_displayObject.parent);
                if (_local2.containsPoint(_arg1)){
                    return (true);
                };
            };
            return (super.isPixelInside(_arg1));
        }
        override public function getToolTipHeader():String{
            var _local1:String;
            var _local2 = "";
            _local1 = Global.player.getFriendFirstName(this.m_friendUID);
            if (_local1 != null){
                _local2 = ZLoc.t("Dialogs", "TrainUI_Joes_Train", {name:ZLoc.tn(_local1)});
            };
            return (_local2);
        }
        public function setSmokeEnabled(_arg1:Boolean):void{
            this.m_smokeEffectOn = ((_arg1) && (this.m_allowSmoke));
            if (((((this.m_smokeEffectOn) && (m_itemImage))) && (!(this.m_trainSmokeEffect)))){
                this.addSmokeEffect();
            };
            if (this.m_trainSmokeEffect){
                this.m_trainSmokeEffect.setIsRunning(this.m_smokeEffectOn);
            };
        }
        public function adjustSmokeForTrainSpeed(_arg1:Number):void{
            if (this.m_trainSmokeEffect){
                this.m_trainSmokeEffect.adjustForTrainSpeed(_arg1);
            };
        }
        override public function setItem(_arg1:Item):void{
            super.setItem(_arg1);
            this.m_allowSmoke = (m_item.smokeXml.@show == "true");
            if (!this.m_allowSmoke){
                this.setSmokeEnabled(false);
            };
        }

    }
}//package Classes 
